﻿
Namespace Components.Lucene.ExistingIndex

    Public Class ExistingIndexDocumentSmartOrdering
        Inherits ExistingIndexDocument

        Public _SmartValue As Nullable(Of Long)

        Public ReadOnly Property HasIdentifier As Boolean
            Get
                Return Not String.IsNullOrEmpty(Uid)
            End Get
        End Property

        Public Function GetSmartOrderingValue(SmartOrderingMethod As Func(Of ExistingIndexDocumentSmartOrdering, Long)) As Long
            If (Not _SmartValue.HasValue) Then
                If SmartOrderingMethod IsNot Nothing Then
                    _SmartValue = SmartOrderingMethod(Me)
                Else
                    Throw New ArgumentNullException("SmartOrderingMethod")
                End If
            End If
            Return _SmartValue.Value
        End Function


    End Class

End Namespace